package com.eos.business.service;

import java.util.List;
import java.util.Map;

import com.eos.common.tool.DaoAccessObjectPoolContextFactory;
import com.eos.orm.c3p0.dao.AbstractC3p0Dao;
import com.eos.orm.c3p0.dao.impl.DeliverListDaoImpl;
import com.eos.orm.c3p0.dao.impl.ReceiptListDaoImpl;
import com.eos.orm.c3p0.dao.impl.ViewDeliverListDaoImpl;
import com.eos.orm.c3p0.dao.impl.ViewReceiptListDaoImpl;
import com.eos.orm.mybatis.dao.DeliverListMapper;
import com.eos.orm.mybatis.dao.ReceiptListMapper;
import com.eos.orm.mybatis.model.DeliverList;
import com.eos.orm.mybatis.model.ReceiptList;
import com.eos.orm.mybatis.model.ViewDeliverList;
import com.eos.orm.mybatis.model.ViewReceiptList;
import com.hf.utils.PaginationBean;

public class SysDeliverReceiptBusinessService extends AbstractEosService<DeliverList>{
	 private AbstractC3p0Dao<DeliverList> deliverListDao = (DeliverListDaoImpl) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("DeliverListDao");
	 private AbstractC3p0Dao<ReceiptList> receiptListDao = (ReceiptListDaoImpl) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("ReceiptListDao");
	 
	 private AbstractC3p0Dao<ViewDeliverList> viewDeliverDao = (ViewDeliverListDaoImpl) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("ViewDeliverListDao");
	 private AbstractC3p0Dao<ViewReceiptList> viewReceiptDao = (ViewReceiptListDaoImpl) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("ViewReceiptListDao");
   
	 private DeliverListMapper  deliverListMapper = (DeliverListMapper) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("DeliverListMapper");
	 private ReceiptListMapper  receiptListMapper = (ReceiptListMapper) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("ReceiptListMapper");
	 
	 /**
	  * 批量保存供应商发货清单
	  * @param deliverList
	  * @return
	  */
	 public String batchSaveDeliverList(List<DeliverList> deliverList){
		 boolean flag =  deliverListDao.save(deliverList);
		 return flag ? "SUCCESS" : "FAIL";
	 }
	 
	 /**
	  * 批量保存结算客户签收单
	  * @param receiptList
	  * @return
	  */
	 public String batchSaveReceiptList(List<ReceiptList> receiptList){
		 boolean flag = receiptListDao.save(receiptList);
		 return flag ? "SUCCESS" : "FAIL";
	 }
	 
	 /**
	  * 分页查询发货单清单数据
	  * @param map
	  * @return
	  */
	 public PaginationBean getDeliverListByView(Map<String, String> map){
		 PaginationBean pageBean = viewDeliverDao.findBean(map);
		 List<ViewDeliverList> vdList = viewDeliverDao.findPage(map);
		 pageBean.setResultList(vdList);
		 return pageBean;
	 }
	 
	 /**
	  * 根据主键修改签收单数据部分信息
	  * @param receipt
	  * @return
	  */
	 public String updateReceiptListPKSelectivce(ReceiptList receipt){
		 return receiptListMapper.updateByPrimaryKeySelective(receipt) ==0 ? "SUCCESS" : "FAIL";
	 }
	 
	 /**
	  * 获取发货单明细数据信息
	  * @param map
	  * @return
	  */
	 public ViewDeliverList getViewDeliverList(Map<String, String> map){
		 List<ViewDeliverList> deliverLists = viewDeliverDao.findByWhere(map);
		 return null != deliverLists && deliverLists.size()>0 ? deliverLists.get(0) : null;
	 }
	 
	 /**
	  * 根据主键修改部分发货单信息
	  * @param deliver
	  * @return
	  */
	 public String updateDeliverListPKSelective(DeliverList deliver){
		 return deliverListMapper.updateByPrimaryKeySelective(deliver)==0 ? "SUCCESS" : "FAIL";
	 }
	 
	 /**
	  * 分页查询发货单清单数据
	  * @param map
	  * @return
	  */
	 public PaginationBean getReceiptListByView(Map<String, String> map){
		 PaginationBean pageBean = viewReceiptDao.findBean(map);
		 List<ViewReceiptList> vdList = viewReceiptDao.findPage(map);
		 pageBean.setResultList(vdList);
		 return pageBean;
	 }
	 
	 /**
	  * 获取签收单单条明细数据
	  * @param map
	  * @return
	  */
	 public ViewReceiptList getViewReceiptList(Map<String, String> map){
		List<ViewReceiptList> list = viewReceiptDao.findByWhere(map);
		return list != null && list.size() >0 ? list.get(0) : null;
	 }
}
